package SyncPools;

import handler.RequestHandler;

import java.io.Serializable;
import java.util.concurrent.Callable;

import syncPoolExecutor.SyncPoolTaskInterface;


import connection.HttpRequest;

public class CallBack implements Callable ,Serializable,SyncPoolTaskInterface{
	private URLConfig config;
	private HttpRequest http;
	private RequestHandler requstManager;
	
	
	public CallBack(URLConfig config,HttpLifeCycleInterface httpLifeCycleInterface) {
		this.config = config;
		http=new HttpRequest(httpLifeCycleInterface);
		requstManager=new RequestHandler(config,http);
		
		
	}
	
	public RequestHandler getRequstManager() {
		return requstManager;
	}

	public Object call() throws Exception {
		// TODO Auto-generated method stub
		switch (config.getRequestType()) {
		case RequestType.POST:
			 requstManager.SendPost();
			break;
		case RequestType.GET:
 			 requstManager.SendGet();
			break;

		default:
			break;
		}

		return null;
	}

	public void setCurrt(int currt) {
		// TODO Auto-generated method stub
		
	}

	public void startTask() {
		// TODO Auto-generated method stub
		try {
			call();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}

	
	
	
	
}
